package de.karlNet.gifSocket.presenter;

import java.awt.AWTException;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;

import de.karlNet.gifSocket.controllers.SessionController;
import java.awt.Rectangle;
import org.apache.http.client.ClientProtocolException;

public class PresenterController extends SessionController {
	private final ArrayList<BufferedImage> imagesToDeliver;
	private int currentImage = 0;
	public PresenterController(String serverUrl,
			ArrayList<BufferedImage> imagesToDeliver) throws AWTException {
		super(serverUrl);
		this.imagesToDeliver = imagesToDeliver;

	}

	@Override
	public String createSession(int x, int y)
			throws ClientProtocolException, IOException {
		String sessionNumber = super.createSession(x,y);
		this.addPictureToSession(Integer.parseInt(sessionNumber), imagesToDeliver.get(this.currentImage));
		this.currentImage++;
		return sessionNumber;
	}
	
	@Override
	public void rightClick(int sessionID, int i, int j) throws ClientProtocolException, IOException {
		System.out.println("click -> previous");
		this.currentImage-=2;
		this.addPictureToSession(sessionID, imagesToDeliver.get(this.currentImage));
		this.currentImage++;
	}

	@Override
	public void click(int sessionID, Integer x, Integer y) throws IOException {
		System.out.println("click -> nextimage");
		this.addPictureToSession(sessionID, imagesToDeliver.get(this.currentImage));
		this.currentImage++;
	}
}
